package com.pbking.facebook.data.data
{
	/**
	 * user preference is a (id, value) pair.
	 * 
	 * id must be between 0-200 (inclusive).
	 * preference is a string of maximum 128 characters.
	 * To "remove" a preference, set it to 0 or empty string. 
	 * Note that, both "0" and "" are considered as "not present", 
	 * and getPreference() call will not return them. To tell them from each other, one can use some serialization format. For example, "n:0" for zeros and "s:" for empty strings. 
	 * 
	 * reference: http://wiki.developers.facebook.com/index.php/Data.setUserPreference
	 */
	public class FacebookUserPreference
	{
		/** minimum value for preference id */
		public const PREF_ID_MIN:int = 0;
		/** maximum value for preference id */
		public const PREF_ID_MAX:int = 200;
		/** max length for value property */
		public const VALUE_MAX_LENGTH:int = 128;
		
		/** id must be between 0-200 */
		public var _pref_id:int;
		/** max length 128 characters */
		public var _value:String;
		
		public function FacebookUserPreference()
		{
		}
		
		public function get pref_id():int
		{
			return _pref_id;
		}
		
		public function set pref_id(newId:int):void
		{
			if (newId < PREF_ID_MIN || newId > PREF_ID_MAX) 
			{
				throw new ArgumentError("UserPreference.pref_id must be between " + PREF_ID_MIN + " and " + PREF_ID_MAX + ".  The argument is " + newId);
			} 
			else 
			{
				_pref_id = newId;
			}
		}
		
		public function get value():String
		{
			return _value;
		}
		
		public function set value(newValue:String):void
		{
			if (newValue.length > VALUE_MAX_LENGTH)
			{
				throw new ArgumentError("UserPreference.value must be less than " + VALUE_MAX_LENGTH + " characters.  The argument is " + newValue);
			}
			else 
			{
				_value = newValue;
			}
		}
	}
}